package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoCollectDoor;
import com.muyu.danmo.service.IDanmoCollectDoorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 拾贝门头照Controller
 *
 * @author yangle
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/collectDoor")
public class DanmoCollectDoorController extends BaseController
{
    @Autowired
    private IDanmoCollectDoorService danmoCollectDoorService;

    /**
     * 查询拾贝门头照列表
     */
//    @RequiresPermissions("system:collectDoor:list")
    @GetMapping("/list")
    public Result list(DanmoCollectDoor danmoCollectDoor)
    {
        startPage();
        List<DanmoCollectDoor> list = danmoCollectDoorService.selectDanmoCollectDoorList(danmoCollectDoor);
        return getDataTable(list);
    }

    /**
     * 导出拾贝门头照列表
     */
//    @RequiresPermissions("system:collectDoor:export")
    @Log(title = "拾贝门头照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoCollectDoor danmoCollectDoor)
    {
        List<DanmoCollectDoor> list = danmoCollectDoorService.selectDanmoCollectDoorList(danmoCollectDoor);
        ExcelUtil<DanmoCollectDoor> util = new ExcelUtil<DanmoCollectDoor>(DanmoCollectDoor.class);
        util.exportExcel(response, list, "拾贝门头照数据");
    }

    /**
     * 获取拾贝门头照详细信息
     */
//    @RequiresPermissions("system:collectDoor:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoCollectDoorService.selectDanmoCollectDoorById(id));
    }

    /**
     * 新增拾贝门头照
     */
//    @RequiresPermissions("system:collectDoor:add")
    @Log(title = "拾贝门头照", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoCollectDoor danmoCollectDoor)
    {
        return toAjax(danmoCollectDoorService.insertDanmoCollectDoor(danmoCollectDoor));
    }

    /**
     * 修改拾贝门头照
     */
//    @RequiresPermissions("system:collectDoor:edit")
    @Log(title = "拾贝门头照", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoCollectDoor danmoCollectDoor)
    {
        return toAjax(danmoCollectDoorService.updateDanmoCollectDoor(danmoCollectDoor));
    }

    /**
     * 删除拾贝门头照
     */
//    @RequiresPermissions("system:collectDoor:remove")
    @Log(title = "拾贝门头照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoCollectDoorService.deleteDanmoCollectDoorByIds(ids));
    }
}
